import React from "react";
import useLoadText from "@/utils/hooks/useLoadText";
import type { LoadedComponentProps } from "@/utils/hooks/useSequentialLoader";

const ChatLoadTitle: React.FC<LoadedComponentProps> = ({ data, onLoad }) => {
  const { showText } = useLoadText(
    data || "",
    {
      loading: !!onLoad,
    },
    {
      onEnd: () => {
        onLoad && onLoad();
      },
    }
  );
  return <>{!!data && <div className="chat-load-title">{showText}</div>}</>;
};

export default ChatLoadTitle;
